package com.imooc.distribute.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;


@RestController
@Slf4j
public class DemoController {

    private Lock lock = new ReentrantLock();

    @RequestMapping("singLock")
    public String singLock(){
        log.info("我进入方法");
        lock.lock();
        log.info("我进入锁");
        try {
            Thread.sleep(60000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            lock.unlock();
        }
        return "我已经执行完成";
    }
}
